package net.chathu.airgw.packets.gw.clientpackets 
{
	import flash.utils.Dictionary;
	import net.chathu.airgw.Config;
	import net.chathu.airgw.model.User;
	import net.chathu.airgw.packets.gw.serverpackets.EchoPacket;
	/**
	 * ...
	 * @author ze
	 */
	public class CMDGWMuteList extends IRCReceivablePacket 
	{
		
		public function CMDGWMuteList() 
		{
			
		}
		
		override public function execute():void {
			
			sendToClient(new EchoPacket(Config.GW_ECHO_NICK, "Némítottak listája:"));
			var ignoreList:Dictionary = sessionData.chatData.ignoreList;
			var cntr:int = 0;
			for (var userRegIdStr:String in ignoreList) {
				cntr++;
				var userRegId:int = parseInt(userRegIdStr);
				var userRegName:String = ignoreList[userRegId];
				var user:User = sessionData.chatData.users.getUserByRegID(userRegId) as User;
				var txt:String;
				var maxLengthStr:String = "                       ";
				if (user) {
					//Online:
					txt = userRegName + " (" +  user.name + ") ";
					sendToClient(new EchoPacket(Config.GW_ECHO_NICK, txt + maxLengthStr.substring(0,Math.max(0,maxLengthStr.length-txt.length)) + Config.IRC_CHAR_COLOR + "9ONLINE"+ Config.IRC_CHAR_COLOR + "  Id: " + userRegId));
				} else {
					//Offline:
					txt = userRegName;
					sendToClient(new EchoPacket(Config.GW_ECHO_NICK, txt + maxLengthStr.substring(0,Math.max(0,maxLengthStr.length-txt.length)) + Config.IRC_CHAR_COLOR + "4OFFLINE"+ Config.IRC_CHAR_COLOR + " Id: " + userRegId));
				}
			}
			
			if (cntr == 0)
			{
				sendToClient(new EchoPacket(Config.GW_ECHO_NICK, "Nem némítottál senkit!"));
			} else {
				sendToClient(new EchoPacket(Config.GW_ECHO_NICK, "Összesen " + cntr + " felhasználót némítottál"));
			}
		}
		
		public static function getShortUsageDescription():String {
			return "Némított felhasználók listája";
		}
		
		public static function getUsageDescription():String {
			return "Példa:\n" +
				"/gwcmutelist\n\n" +
				"Eredmény:\n\n" + 
				"Némítottak listája:\n" +
				"gipsz jakab			              "+ Config.IRC_CHAR_COLOR + "4OFFLINE"+ Config.IRC_CHAR_COLOR + " Id: 1234567\n" + 
				"fül elek			              "+ Config.IRC_CHAR_COLOR + "9ONLINE"+ Config.IRC_CHAR_COLOR + " Id: 2345678\n" + 
				"Összesen 2 felhasználót némítottál";
		}		
	}

}